package YiChang;




class UserNameException extends Exception{
    public UserNameException(String message){
        super(message);
    }
}

class PasswordException extends Exception{
    public PasswordException(String message){
        super(message);
    }
}

public  class Login{
    private  String userName = "admin";
    private  String password = "123456";

    public static  void logininfo(String userName ,String password)
        throws UserNameException,PasswordException{
        if (!userName.equals(userName)){
            throw new UserNameException("用户名错误");
        }
        if (!password.equals(password)){
            throw new PasswordException("用户名错误");
        }
        System.out.println("登录成功");

    }

    public static void main(String[] args) {
        try{
            logininfo("admin","123456");
        }catch (UserNameException e){
            e.printStackTrace();
        }catch (PasswordException e){
            e.printStackTrace();
        }
    }
}